const CONFIG = {
  eproxy: "PROXY home.zzon.net:8011",
  efinal: "DIRECT",
  enable: true,
  mitmall: false,
  mitmhost: ["api.m.jd.com","blackhold.m.jd.com","rjsb-token-m.jd.com"],
}

function FindProxyForURL(url, host) {
  if (CONFIG.enable === false) {
    return CONFIG.efinal
  }
  if (CONFIG.mitmall) {
    return CONFIG.eproxy
  }
  if (CONFIG.mitmhost.indexOf(host) !== -1) {
    return CONFIG.eproxy
  }
  for (let h of CONFIG.mitmhost) {
    if (/\*/.test(h) && new RegExp(h.replace(/\./g, '\\.').replace(/\*/g, '.*')).test(host)) {
      return CONFIG.eproxy
    }
  }
  return CONFIG.efinal
}